<?php

namespace app\factory\controller;

use app\common\respond\HttpApi;
use app\factory\logic\FenceLogic;

class FenceController
{
    /**
     * @Description 新增/编辑
     * @author: zj
     * @param HttpApi $respond
     * @time 2024/03/11 17:29:13
     * @return \think\response\Json
     */
    public function addEdit(HttpApi $respond)
    {
        $param = [
            'Id' => request()->post('Id'),
            'BarnId' => request()->post('BarnId'),
            'Name' => request()->post('Name'),
            'DeviceId' => request()->post('DeviceId'),
            'FeedBaseTime' => request()->post('FeedBaseTime'),
            'FeedPreDayId' => request()->post('FeedPreDayId') ?: 0,
            'isLoop' => request()->post('isLoop'),
            'Remark' => request()->post('Remark') ?: '',
            'RecordTime' => request()->post('RecordTime'),
        ];
        $rule = [
            'Id' => 'require|integer|>:0',
            'Remark' => 'max:255',
            'RecordTime' => 'require|integer|>:0',
        ];
        validate($rule)->check($param);

        $logic = new FenceLogic();
        $data = $logic->addEdit($param['Id'],$param);

        return $respond->success([]);
    }

}